package encrypt

import (
	"encoding/base64"
	"log"

	"golang.org/x/crypto/scrypt"
)

// EncryptPassword 使用scrypt加密密码
func EncryptPassword(password string) (finalPassword string) {
	const KeyLen = 10

	salt := make([]byte, 8)
	salt = []byte{32, 54, 98, 15, 78, 65, 14, 63, 255}

	dk, err := scrypt.Key([]byte(password), salt, 1<<13, 8, 1, KeyLen)
	if err != nil {
		log.Fatal(err)
	}
	return base64.StdEncoding.EncodeToString(dk)
}
